home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / arpa / RCS / nameser.h,v < prev    next >
Encoding:
Text File  |  1990-11-07  |  7.7 KB  |  319 lines

  1. head     1.5;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.5
  10. date     90.11.06.17.25.04;  author rab;  state Exp;
  11. branches ;
  12. next     1.4;
  13.  
  14. 1.4
  15. date     88.08.31.20.20.31;  author mendel;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.06.29.15.16.00;  author ouster;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.06.26.15.36.34;  author ouster;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.06.26.15.30.28;  author ouster;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 1.5
  40. log
  41. @Added prototypes.  Changed extern to _EXTERN for g++.
  42. @
  43. text
  44. @/*
  45.  * Copyright (c) 1983 Regents of the University of California.
  46.  * All rights reserved.  The Berkeley software License Agreement
  47.  * specifies the terms and conditions for redistribution.
  48.  *
  49.  *    @@(#)nameser.h    5.17 (Berkeley) 11/17/87
  50.  */
  51.  
  52. #ifndef _NAMESER_H
  53. #define _NAMESER_H
  54.  
  55. #include <cfuncproto.h>
  56. #include <machparam.h>
  57.  
  58. /*
  59.  * Define constants based on rfc883
  60.  */
  61. #define PACKETSZ    512        /* maximum packet size */
  62. #define MAXDNAME    256        /* maximum domain name */
  63. #define MAXCDNAME    255        /* maximum compressed domain name */
  64. #define MAXLABEL    63        /* maximum length of domain label */
  65.     /* Number of bytes of fixed size data in query structure */
  66. #define QFIXEDSZ    4
  67.     /* number of bytes of fixed size data in resource record */
  68. #define RRFIXEDSZ    10
  69.  
  70. /*
  71.  * Internet nameserver port number
  72.  */
  73. #define NAMESERVER_PORT    53
  74.  
  75. /*
  76.  * Currently defined opcodes
  77.  */
  78. #define QUERY        0x0        /* standard query */
  79. #define IQUERY        0x1        /* inverse query */
  80. #define STATUS        0x2        /* nameserver status query */
  81. /*#define xxx        0x3        /* 0x3 reserved */
  82.     /* non standard */
  83. #define UPDATEA        0x9        /* add resource record */
  84. #define UPDATED        0xa        /* delete a specific resource record */
  85. #define UPDATEDA    0xb        /* delete all nemed resource record */
  86. #define UPDATEM        0xc        /* modify a specific resource record */
  87. #define UPDATEMA    0xd        /* modify all named resource record */
  88.  
  89. #define ZONEINIT    0xe        /* initial zone transfer */
  90. #define ZONEREF        0xf        /* incremental zone referesh */
  91.  
  92. /*
  93.  * Currently defined response codes
  94.  */
  95. #define NOERROR        0        /* no error */
  96. #define FORMERR        1        /* format error */
  97. #define SERVFAIL    2        /* server failure */
  98. #define NXDOMAIN    3        /* non existent domain */
  99. #define NOTIMP        4        /* not implemented */
  100. #define REFUSED        5        /* query refused */
  101.     /* non standard */
  102. #define NOCHANGE    0xf        /* update failed to change db */
  103.  
  104. /*
  105.  * Type values for resources and queries
  106.  */
  107. #define T_A        1        /* host address */
  108. #define T_NS        2        /* authoritative server */
  109. #define T_MD        3        /* mail destination */
  110. #define T_MF        4        /* mail forwarder */
  111. #define T_CNAME        5        /* connonical name */
  112. #define T_SOA        6        /* start of authority zone */
  113. #define T_MB        7        /* mailbox domain name */
  114. #define T_MG        8        /* mail group member */
  115. #define T_MR        9        /* mail rename name */
  116. #define T_NULL        10        /* null resource record */
  117. #define T_WKS        11        /* well known service */
  118. #define T_PTR        12        /* domain name pointer */
  119. #define T_HINFO        13        /* host information */
  120. #define T_MINFO        14        /* mailbox information */
  121. #define T_MX        15        /* mail routing information */
  122.     /* non standard */
  123. #define T_UINFO        100        /* user (finger) information */
  124. #define T_UID        101        /* user ID */
  125. #define T_GID        102        /* group ID */
  126. #define T_UNSPEC    103        /* Unspecified format (binary data) */
  127.     /* Query type values which do not appear in resource records */
  128. #define T_AXFR        252        /* transfer zone of authority */
  129. #define T_MAILB        253        /* transfer mailbox records */
  130. #define T_MAILA        254        /* transfer mail agent records */
  131. #define T_ANY        255        /* wildcard match */
  132.  
  133. /*
  134.  * Values for class field
  135.  */
  136.  
  137. #define C_IN        1        /* the arpa internet */
  138. #define C_CHAOS        3        /* for chaos net at MIT */
  139.     /* Query class values which do not appear in resource records */
  140. #define C_ANY        255        /* wildcard match */
  141.  
  142. /*
  143.  * Status return codes for T_UNSPEC conversion routines
  144.  */
  145. #define CONV_SUCCESS 0
  146. #define CONV_OVERFLOW -1
  147. #define CONV_BADFMT -2
  148. #define CONV_BADCKSUM -3
  149. #define CONV_BADBUFLEN -4
  150.  
  151. /*
  152.  * Structure for query header, the order of the fields is machine and
  153.  * compiler dependent, in our case, the bits within a byte are assignd 
  154.  * least significant first, while the order of transmition is most 
  155.  * significant first.  This requires a somewhat confusing rearrangement.
  156.  */
  157.  
  158. typedef struct {
  159.     u_short    id;        /* query identification number */
  160. #if defined (sun) || defined (sel) || defined (pyr) || defined (is68k) \
  161. || defined (tahoe) || defined (BIT_ZERO_ON_LEFT) || (BYTE_ORDER == BIG_ENDIAN)
  162.     /* Bit zero on left:  Gould and similar architectures */
  163.             /* fields in third byte */
  164.     u_char    qr:1;        /* response flag */
  165.     u_char    opcode:4;    /* purpose of message */
  166.     u_char    aa:1;        /* authoritive answer */
  167.     u_char    tc:1;        /* truncated message */
  168.     u_char    rd:1;        /* recursion desired */
  169.             /* fields in fourth byte */
  170.     u_char    ra:1;        /* recursion available */
  171.     u_char    pr:1;        /* primary server required (non standard) */
  172.     u_char    unused:2;    /* unused bits */
  173.     u_char    rcode:4;    /* response code */
  174. #else
  175. #if defined (vax) || defined(ns32000) || defined (BIT_ZERO_ON_RIGHT) \
  176. || (BYTE_ORDER == LITTLE_ENDIAN)
  177.     /* Bit zero on right:  VAX */
  178.             /* fields in third byte */
  179.     u_char    rd:1;        /* recursion desired */
  180.     u_char    tc:1;        /* truncated message */
  181.     u_char    aa:1;        /* authoritive answer */
  182.     u_char    opcode:4;    /* purpose of message */
  183.     u_char    qr:1;        /* response flag */
  184.             /* fields in fourth byte */
  185.     u_char    rcode:4;    /* response code */
  186.     u_char    unused:2;    /* unused bits */
  187.     u_char    pr:1;        /* primary server required (non standard) */
  188.     u_char    ra:1;        /* recursion available */
  189. #else
  190.     /* you must determine what the correct bit order is for your compiler */
  191.     UNDEFINED_BIT_ORDER;
  192. #endif
  193. #endif
  194.             /* remaining bytes */
  195.     u_short    qdcount;    /* number of question entries */
  196.     u_short    ancount;    /* number of answer entries */
  197.     u_short    nscount;    /* number of authority entries */
  198.     u_short    arcount;    /* number of resource entries */
  199. } HEADER;
  200.  
  201. /*
  202.  * Defines for handling compressed domain names
  203.  */
  204. #define INDIR_MASK    0xc0
  205.  
  206. /*
  207.  * Structure for passing resource records around.
  208.  */
  209. struct rrec {
  210.     short    r_zone;            /* zone number */
  211.     short    r_class;        /* class number */
  212.     short    r_type;            /* type number */
  213.     u_long    r_ttl;            /* time to live */
  214.     int    r_size;            /* size of data area */
  215.     char    *r_data;        /* pointer to data */
  216. };
  217.  
  218. _EXTERN    u_short    _getshort _ARGS_((_CONST u_char *msgp));
  219. _EXTERN    u_long    _getlong _ARGS_((_CONST u_char *msgp));
  220. _EXTERN void putshort _ARGS_ ((u_short s, u_char *msgp));
  221. _EXTERN void putlong _ARGS_ ((u_long s, u_char *msgp));
  222.  
  223. /*
  224.  * Inline versions of get/put short/long.
  225.  * Pointer is advanced; we assume that both arguments
  226.  * are lvalues and will already be in registers.
  227.  * cp MUST be u_char *.
  228.  */
  229. #define GETSHORT(s, cp) { \
  230.     (s) = *(cp)++ << 8; \
  231.     (s) |= *(cp)++; \
  232. }
  233.  
  234. #define GETLONG(l, cp) { \
  235.     (l) = *(cp)++ << 8; \
  236.     (l) |= *(cp)++; (l) <<= 8; \
  237.     (l) |= *(cp)++; (l) <<= 8; \
  238.     (l) |= *(cp)++; \
  239. }
  240.  
  241.  
  242. #define PUTSHORT(s, cp) { \
  243.     *(cp)++ = (s) >> 8; \
  244.     *(cp)++ = (s); \
  245. }
  246.  
  247. /*
  248.  * Warning: PUTLONG destroys its first argument.
  249.  */
  250. #define PUTLONG(l, cp) { \
  251.     (cp)[3] = l; \
  252.     (cp)[2] = (l >>= 8); \
  253.     (cp)[1] = (l >>= 8); \
  254.     (cp)[0] = l >> 8; \
  255.     (cp) += sizeof(u_long); \
  256. }
  257.  
  258. #endif /* _NAMESER_H */
  259. @
  260.  
  261.  
  262. 1.4
  263. log
  264. @Corrected #if for byte ordering.
  265. @
  266. text
  267. @d9 2
  268. a10 2
  269. #ifndef _NAMESER
  270. #define _NAMESER
  271. d12 1
  272. d175 4
  273. a178 2
  274. extern    u_short    _getshort();
  275. extern    u_long    _getlong();
  276. d215 1
  277. a215 1
  278. #endif _NAMESER
  279. @
  280.  
  281.  
  282. 1.3
  283. log
  284. @Add ifdefs so that file can't be processed twice.
  285. @
  286. text
  287. @d117 1
  288. a117 1
  289. || defined (tahoe) || defined (BIT_ZERO_ON_LEFT) || defined(BIG_ENDIAN)
  290. d132 1
  291. a132 1
  292. || defined(LITTLE_ENDIAN)
  293. @
  294.  
  295.  
  296. 1.2
  297. log
  298. @Make sure that byte order is defined correctly.
  299. @
  300. text
  301. @d9 3
  302. d211 2
  303. @
  304.  
  305.  
  306. 1.1
  307. log
  308. @Initial revision
  309. @
  310. text
  311. @d9 2
  312. d114 1
  313. a114 1
  314. || defined (tahoe) || defined (BIT_ZERO_ON_LEFT)
  315. d128 2
  316. a129 1
  317. #if defined (vax) || defined(ns32000) || defined (BIT_ZERO_ON_RIGHT)
  318. @
  319.